# -*- coding: utf-8 -*-
"""
****************************
@Time    : 2021/4/25 16:22
@Author  : Candy
@File    : user.py
****************************
"""
import re

VALID_NAME = re.compile('^[A-Za-z0-9\u4e00-\u9fa5]{2,16}$')
VALID_PWD = re.compile('^[A-Za-z0-9]{6,16}$')
VALID_TEL = re.compile('^1[356789][0-9]{9}$')


def check_pwd(pwd):
    res = VALID_PWD.search(pwd.strip())
    return True if res else False


def check_name(name):
    res = VALID_NAME.search(name.strip())
    return True if res else False


def check_tel(tel):
    res = VALID_TEL.search(tel.strip())
    return True if res else False


def check_name_pwd_tel(name, pwd, tel):
    return check_name(name) and check_pwd(pwd) and check_name(tel)


def check_pwd_tel(pwd, tel):
    return check_pwd(pwd) and check_name(tel)
